//
// Created by 25238 on 2024-01-11.
//

#ifndef SELECTION_SORT_SELECTIONSORT_H
#define SELECTION_SORT_SELECTIONSORT_H

#include <iostream>
#include <algorithm>

using namespace std;

template<typename T>
void selectionSort(T arr[], int n){
    for(int i = 0; i < n ; i++){
        // 找最小值
        int minIndex = i;
        for(int j = i + 1; j < n; j++)
            if(arr[j] < arr[minIndex])
                minIndex = j;
        swap(arr[i], arr[minIndex]);
    }
}

#endif //SELECTION_SORT_SELECTIONSORT_H
